﻿
using ZFine.Code;
using ZFine.Domain.IRepository.SystemManage;
using ZFine.Repository.SystemManage;
using System;
using System.Collections.Generic;
using System.Linq;
using Logic.Repository.Project;
using ZFine.Domain.Entity;

namespace ZFine.Application.Project
{
    public class MemberApp
    {
        private IMemberRepository service = new MemberRepository();

        public List<MemberEntity> GetList()
        {
            return service.IQueryable().ToList();
        }

        public List<MemberEntity> GetList(Pagination pagination, string keyword)
        {
            MemberEntity member = service.FindEntitys();
            member.RealName = "1111asdf";
            member.MerchantP=new UserEntity{F_Id = "9f2ec079-7d0f-4fe2-90ab-8b09a8302a12" };
            service.Update(member);
            //var thisdd = service.FindList(pagination);
            //var thisss = service.FindEntitys();
              var expression = ExtLinq.True<MemberEntity>();
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.RealName.Contains(keyword));
            }
            return service.FindList(pagination);
        }

        public MemberEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }
        public void DeleteForm(string keyValue)
        {
            //if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
            //{
            //    throw new Exception("删除失败！操作的对象包含了下级数据。");
            //}
            //else
            //{
                service.Delete(t => t.F_Id == keyValue);
            //}
        }
        public void SubmitForm(MemberEntity areaEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                areaEntity.Modify(keyValue);
                service.Update(areaEntity);
            }
            else
            {
                areaEntity.Create();
                service.InsertEnt(areaEntity);
            }
        }
    }
}
